// 版本
var version= "V5.3";
// 设置页面ip;
var configureIp="39.105.228.226:8070";
// 全局的url 39.105.228.226:8070
var domain = "http://" + configureIp;
//故障记录接口
var ip = localStorage.getItem('ip');
var port = localStorage.getItem('port');
var gzmain = 'http://' + ip + ':' + port;
//记录页数
var Dpage = 10;
function getNowFormatDate() {
	var date = new Date();
	var seperator1 = "-";
	var seperator2 = ":";
	var month = date.getMonth() + 1;
	var strDate = date.getDate();
	if (month >= 1 && month <= 9) {
		month = "0" + month;
	}
	if (strDate >= 0 && strDate <= 9) {
		strDate = "0" + strDate;
	}
	var sec = date.getSeconds();// 解决秒小于10的是,前面补0
	sec=parseInt(sec)<10 ?'0'+sec:sec;
	
	var minu = date.getMinutes();// 解决秒小于10的是,前面补0
	minu=parseInt(minu)<10 ?'0'+minu:minu;
	
	var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate +
		" " + date.getHours() + seperator2 + minu +
		seperator2 + sec;
	return currentdate;
}
function dataURItoBlob(base64Data) {
	var byteString;
	if (base64Data.split(',')[0].indexOf('base64') >= 0)
		byteString = atob(base64Data.split(',')[1]);
	else
		byteString = unescape(base64Data.split(',')[1]);
	var mimeString = base64Data.split(',')[0].split(':')[1].split(';')[0];
	var ia = new Uint8Array(byteString.length);
	for (var i = 0; i < byteString.length; i++) {
		ia[i] = byteString.charCodeAt(i);
	}
	return new Blob([ia], {
		type: mimeString
	});
}
// //地图
// // 3000消息,准备传递坐标消息

// 动态生成链接
var dlgStr='<a href="dt:req=get_loc" id="get_loc"></a>';
$('body').append(dlgStr);
function  set_loc(lat,lng,speed,alt){
		//console.log('set_loc被调用 '+lat+", "+lng);
		if(lat && lng){
			lat = Math.floor(lat * 100000) / 100000;
			lng = Math.floor(lng * 100000) / 100000;
		}
		$("body").attr("data-lat",lat);
		$("body").attr("data-lng",lng);		
		//2019-01-08 坐标不需要太实时,不需要清理,就需要每次都更新
		localStorage.setItem('wbapplat',lat);
		localStorage.setItem('wbapplng',lng);
	
		var userid = localStorage.getItem('userid');
		var token = localStorage.getItem('token');	
		var url = domain + "/dtwbgl/upmsg.h5";
		var datapos = {
			userid: userid,
			long: lng,
			lat: lat,
			token: token,
		}
		$.ajax(url, {
			data: JSON.stringify(datapos),
			dataType: 'json', //服务器返回json格式数据
			type: 'post', //HTTP请求类型
			timeout: 20000, //超时时间
			async: true, //true异步加载
			success: function(data) {
				if (data.code == 2001) {
					console.log(data);
				} else if (data.code == 2003) {
					alert(data);
				}
			},
			error: function(xhr, type, errorThrown) { //异常处理； console.log(type);		
			},
		});		
}
var timer
//先清除
clearInterval(timer);
//再调用
timer = window.setInterval(function(){
	//set_loc('40.0058',"116.4117",'20','1')
	$("#get_loc")[0].click();
},5000);


